package com.neuedu.web;

import com.neuedu.pojo.*;
import com.neuedu.service.ClueTableService;
import com.neuedu.service.VisitInfoService;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/Village")
@Tag(name="乡村干部管理线索")

public class VillageController {
    @Resource
    private ClueTableService clueTableService;

    @Resource
    private VisitInfoService visitInfoService;

    //乡村干部更新线索状态字段
    @PutMapping("/update-currentStage")
    public Result<Void> updateCurrentStage(@RequestParam(name = "clueId")Integer clueId,
                                           @RequestParam(name = "currentStage")String currentStage) {
        return this.clueTableService.updateCurrentStage(clueId,currentStage);
    }

    @GetMapping("/getClueTables")
    public Result<List<ClueTable>> getClueTables(
            @RequestParam(name = "currentPage",defaultValue = "1")Integer currentPage,
            @RequestParam(name = "pageSize",defaultValue = "10")Integer pageSize,
            @RequestParam(name = "responsibleCadreid",defaultValue = "")Integer responsibleCadreid) {
        return this.clueTableService.getClueTables(currentPage,pageSize,responsibleCadreid);
    }

    @GetMapping("/getVisitInfo")
    public Result<List<VisitInfo>> getVisitInfo(
            @RequestParam(name = "currentPage",defaultValue = "1")Integer currentPage,
            @RequestParam(name = "pageSize",defaultValue = "10")Integer pageSize,
            @RequestParam(name = "belongArea",defaultValue = "")String belongArea) {
        return this.visitInfoService.getVisitInfo(currentPage,pageSize,belongArea);
    }

    @GetMapping("/getClueTablesByArea")
    public Result<List<ClueTable>> getClueTablesByArea(
            @RequestParam(name = "currentPage",defaultValue = "1")Integer currentPage,
            @RequestParam(name = "pageSize",defaultValue = "10")Integer pageSize,
            @RequestParam(name = "belongArea",defaultValue = "")String belongArea) {
        return this.clueTableService.getClueTablesByArea(currentPage,pageSize,belongArea);
    }

    @PostMapping("/addVisitInfo")
    public Result<Void> addVisitInfo(@RequestBody VisitInfo visitInfo) {
        return this.visitInfoService.addVisitInfo(visitInfo);
    }


    @DeleteMapping("deleteVisitInfo/{id}")
    public Result<Void> deleteVisitInfo(@PathVariable("id") Integer id) {
        return this.visitInfoService.deleteVisitInfo(id);
    }

    @PutMapping("/updateVisitInfo")
    public Result<Void> updateVisitInfo(@RequestBody VisitInfo visitInfo) {
        return this.visitInfoService.updateVisitInfo(visitInfo);
    }

}
